package com.dev.ac.web.server;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dev.ac.annotation.Login;
import com.dev.ac.common.Const;
import com.dev.ac.common.Result;
import com.dev.ac.entity.AApplication;
import com.dev.ac.entity.AUser;
import com.dev.ac.service.AApplicationService;
import com.dev.ac.service.AUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author 付
 * @Date 2024-04-15 15:46
 * @Version 1.0
 * @description 管理员审核表
 * @since 1.0
 */
@RestController
@RequestMapping("/admin/application")
public class AdminApplicationController {
	@Autowired
	AApplicationService aApplicationService;
	@Autowired
	AUserService aUserService;

	@GetMapping("/list")
//	@Login(issuer = Const.GRADE_ADMIN)
	public Result list(Integer currentPage) {
		Page<AApplication> page = aApplicationService.page(new Page<>(currentPage, 20), new QueryWrapper<AApplication>()
				.orderByDesc("create_time")
		);
		for (AApplication aApplication : page.getRecords()) {
			AUser aUser = aUserService.getById(aApplication.getUserId());
			aApplication.setAUser(aUser);
		}
		return Result.success(page);
	}
}
